# -*- coding: utf-8 -*-
import scrapy


class DingdianSpiderSpider(scrapy.Spider):
    name = 'dingdian_spider'
    # allowed_domains = ['xxx']
    start_urls = ['https://www.booktxt.net/2_2219/1485868.html']

    def parse(self, response):
        title = response.xpath("//div[@class='bookname']/h1/text()")[0].extract()
        next_part = 'https://www.booktxt.net/2_2219/' + response.xpath("//div[@class='bottem1']/a[4]/@href")[
            0].extract()
        print(title)
        yield scrapy.Request(url=next_part, callback=self.parse)
